/*     */ package com.qmsk.business.member.memberService.controller;
/*     */ 
/*     */ import com.qmsk.business.member.memberService.dao.MemberServiceDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/memberService"})
/*     */ public class MemberServiceController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(MemberServiceController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberServiceDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  54 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  56 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/*  57 */         nPageSize);
/*  58 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  60 */       logger.error(e);
/*  61 */       ResponseUtils.setErrorMsgResponse(
/*  62 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/levelId/{shopId}/{levelId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAllShopIdLevelId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("levelId") Integer levelId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  73 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  75 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdAndLevelId(shopId, 
/*  76 */         levelId, nPageIdx, nPageSize);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/levelId/{levelId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAllLevelId(HttpServletRequest request, HttpServletResponse response, @PathVariable("levelId") Integer levelId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  91 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  93 */       GsonEbRst gsonEbRst = this.dao.getGsonOfLevelId(
/*  94 */         levelId, nPageIdx, nPageSize);
/*  95 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  97 */       logger.error(e);
/*  98 */       ResponseUtils.setErrorMsgResponse(
/*  99 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 115 */     String sGsonInData = request.getParameter("data");
/*     */     try
/*     */     {
/* 118 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 119 */       if (nResult > 0)
/* 120 */         DbConnection.commit();
/*     */       else {
/* 122 */         DbConnection.rollback();
/*     */       }
/* 124 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 125 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 126 */         response);
/*     */     } catch (Exception e) {
/* 128 */       DbConnection.rollback();
/* 129 */       logger.error(e);
/* 130 */       ResponseUtils.setErrorMsgResponse(
/* 131 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 132 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response) {
/* 139 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 141 */       String[] strParams = id.split(",");
/* 142 */       int nResult = this.dao.deleteParams(strParams);
/* 143 */       DbConnection.commit();
/* 144 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 145 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 146 */         response);
/*     */     } catch (Exception e) {
/* 148 */       DbConnection.rollback();
/* 149 */       logger.error(e);
/* 150 */       ResponseUtils.setErrorMsgResponse(
/* 151 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 152 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 168 */     String id = request.getParameter("id");
/* 169 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 171 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 172 */       if (g == null) {
/* 173 */         ResponseUtils.setErrorMsgResponse(
/* 174 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 175 */           response);
/*     */       } else {
/* 177 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 178 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 179 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 180 */           response);
/*     */       }
/* 182 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 184 */       DbConnection.rollback();
/* 185 */       logger.error(e);
/* 186 */       ResponseUtils.setErrorMsgResponse(
/* 187 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + 
/* 188 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberService.controller.MemberServiceController
 * JD-Core Version:    0.5.3
 */